﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace com.huawei.ebg.esdk.ucsdk.client.control
{
    internal static class Utilities
    {
        internal static bool ItemExisted(string item)
        {
            if (item != null && item != string.Empty)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        internal static Point GetClientLocation(Control myControl, Control PopupControl)
        {
            Point location = myControl.PointToScreen(new Point(myControl.ClientRectangle.Left, myControl.ClientRectangle.Bottom));
            Rectangle screen = Screen.FromControl(myControl).WorkingArea;

            if (location.X + PopupControl.Size.Width > (screen.Left + screen.Width))
            {
                location.X = (screen.Left + screen.Width) - PopupControl.Size.Width;
            }

            if (location.Y + PopupControl.Size.Height > (screen.Top + screen.Height))
            {
                location.Y -= PopupControl.Size.Height + myControl.ClientRectangle.Height;
            }
            return myControl.PointToClient(location);
        }
    }
}
